package com.lixin.smartclassroom.ext

import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import com.lixinkeji.extension.get
import com.lixinkeji.extension.set
import com.lixinkeji.extension.sharedPreferences


/**
 * 用户信息
 */
//var Activity.user: UserInfo?
//    get() {
//        val json = sharedPreferences["user",""]
//        val json1 = sharedPreferences["user",UserInfo().userInfo]
//        return if (json.isNullOrEmpty()) null
//        else Gson().fromJson(json, UserInfo::class.java)
//    }
//    set(value) {
//        sharedPreferences["user"] = value?.toJson() ?: ""
//    }
//
//var Context.user: UserInfo?
//    get() {
//        val json = sharedPreferences["user", ""]
//        return if (json.isNullOrEmpty()) null
//        else Gson().fromJson(json, UserInfo::class.java)
//    }
//    set(value) {
//        sharedPreferences["user"] = value?.toJson() ?: ""
//    }

var Activity.allGroupIdList:String
    get() = sharedPreferences["allGroupIdList", ""]!!
    set(value) = sharedPreferences.set("allGroupIdList", value)

var Context.allGroupIdList: String
    get() = sharedPreferences["allGroupIdList", ""]!!
    set(value) = sharedPreferences.set("allGroupIdList", value)

/**
 * 是否同意隐私协议或服务协议
 */
var Activity.isAgree: Boolean
    get() = sharedPreferences["isAgree", false]!!
    set(value) {
        sharedPreferences["isAgree"] = value
    }
var Context.isAgree: Boolean
    get() = sharedPreferences["isAgree", false]!!
    set(value) {
        sharedPreferences["isAgree"] = value
    }

var Activity.isFirstLogin: Boolean
    get() = sharedPreferences["isFirstLogin", true]!!
    set(value) {
        sharedPreferences["isAgree"] = value
    }
var Context.isFirstLogin: Boolean
    get() = sharedPreferences["isFirstLogin", true]!!
    set(value) {
        sharedPreferences["isAgree"] = value
    }


var Activity.chapterPosition: Int
    get() = sharedPreferences["chapterPosition", 1]!!
    set(value) {
        sharedPreferences["chapterPosition"] = value
    }
var Context.chapterPosition: Int
    get() = sharedPreferences["chapterPosition", 1]!!
    set(value) {
        sharedPreferences["chapterPosition"] = value
    }

/**
 * IM token
 */
var Activity.im_token: String
    get() = sharedPreferences["im_token", ""]!!
    set(value) = sharedPreferences.set("im_token", value)
var Context.im_token: String
    get() = sharedPreferences["im_token", ""]!!
    set(value) = sharedPreferences.set("im_token", value)

var Activity.user_role: Int
    get() = sharedPreferences["user_role", 0]!!
    set(value) = sharedPreferences.set("user_role", value)
var Context.user_role: Int
    get() = sharedPreferences["user_role", 0]!!
    set(value) = sharedPreferences.set("user_role", value)

var Activity.user_image: String
    get() = sharedPreferences["user_image", ""]!!
    set(value) = sharedPreferences.set("user_image", value)
var Context.user_image: String
    get() = sharedPreferences["user_image", ""]!!
    set(value) = sharedPreferences.set("user_image", value)


var Activity.user_name: String
    get() = sharedPreferences["user_name", ""]!!
    set(value) = sharedPreferences.set("user_name", value)
var Context.user_name: String
    get() = sharedPreferences["user_name", ""]!!
    set(value) = sharedPreferences.set("user_name", value)
var Activity.child_id: String
    get() = sharedPreferences["child_id", ""]!!
    set(value) = sharedPreferences.set("child_id", value)
var Context.child_id: String
    get() = sharedPreferences["child_id", ""]!!
    set(value) = sharedPreferences.set("child_id", value)
var Activity.child_name: String
    get() = sharedPreferences["child_name", ""]!!
    set(value) = sharedPreferences.set("child_name", value)
var Context.child_name: String
    get() = sharedPreferences["child_name", ""]!!
    set(value) = sharedPreferences.set("child_name", value)


